import React from "react";
import { BrowserRouter, Routes, Route, useRoutes } from "react-router-dom";
const Home = React.lazy(() => import("../views/home"));
const Car = React.lazy(() => import("../views/car"));
const SelectCity = React.lazy(() => import("../views/selectCity"));
const MainLayout = React.lazy(() => import("../views/mainLayout"));

export const layoutRoutes = [
  {
    path: "/",
    element: <Home></Home>,
    title: "首页",
  },
  {
    path: "/car",
    element: <Car></Car>,
    title: "车",
  },
  {
    path: "/select/city",
    element: <SelectCity></SelectCity>,
    title: "城市",
  },
]

const routes = [
  {
    path: "/",
    element: <MainLayout></MainLayout>,
    children: layoutRoutes,
  },
];

const Index: React.FC = () => {
  const App = () => {
    const element = useRoutes(routes);
    return element;
  };
  return (
    <BrowserRouter>
      <App></App>
    </BrowserRouter>
  );
};

export default Index;
